#!/bin/bash
#set -n
. $I/setopsys.sh
set -x
if (( is_cygwin == 1 )) ; then
  antcmd=ant.bat
else
  antcmd=ant
fi
rm -f $II/whyc $II/whycp
echo "original parms=$*" 2>&1 | tee $II/whycp
echo "antcmd=$antcmd" 2>&1 | tee -a $II/whycp
if [[ "$1" = "-fn" ]] ; then
	pfn="$2"
	pfnparm="-Dpresrc.file=$pfn"
	pfnbaseparm="-Dpresrc.file.base=$(basename $pfn)"
	pfndirtmp="${mympfile##$mycdsvnp/}"
	pfndir="$(dirname $pfndirtmp)"
	pdirparm="-Dpresrc.dir=$pfndir"
	pmdir="${pfndir%%/*}"
	pmdirparm="-Dpresrc.mdir=$pmdir"
	sdir="${pfndir##$pmdir/}"
	sdirparm="-Dsrc.dir=$sdir"
	pfndrsub="${pfndirtmp##$pmdir/}"
	pfndroot="${pfndrsub%%.java}"
	pfndclass="$pfndroot.class"
	rm -f $mycdsvnp/target/*/$pfndclass
#undo remove rm -f $mycdsvnp/target/*/$pfndrsub
	shift 2
fi
ndir="$1"
shift 1
if [[ "$1" = "-f" ]] ; then
	bfn="$2"
	bfnparm="-f $bfn"
	shift 2
fi
echo "new parms=$*" 2>&1 | tee -a $II/whycp
anteval="$antcmd $bfnparm $pfnparm $pfnbaseparm  $pdirparm $pmdirparm $sdirparm $* "
echo "anteval=$anteval" | tee -a $II/whycp
cp $II/whyc $II/whycp
cd "$ndir";eval "$anteval" 2>&1 | tee -a $II/whycp | $i/preproc.pl 2>&1 | tee -a $II/whyc
# sed \
#	-e 's#\\src\(.*\)\(M[Ii][Dd]let\)#\\presrc\1\2#' 2>&1 
